1. Field of the Invention
The present invention relates to an image processing method and apparatus that compresses image data.
2. Description of the Related Art
Conventionally, various techniques are used as methods for compressing image data, and one of those is a method referred to as “BTC (Block Truncation Coding)”.
In this method, image data (referred to below as simply an “image”) is partitioned into a plurality of blocks, and by reducing the number of colors in the blocks by expressing pixels in each block as an approximate color (a representative color), the amount of data is reduced.
Specifically, for example, this method involves the following. First, an average value of the darkness value of the pixels in the partitioned blocks is obtained, and those pixels are divided into a group of pixels with a darkness value higher than the average value and a group of pixels with a darkness value lower than the average value. Furthermore, an average value of the darkness value is obtained for each group. Then, a color expressed by that average value is set as an approximate color of that group. More specifically, the color of all pixels in that group is set to the same approximate color. Such processing is performed for all blocks included in the image data. As technology related to this BTC, methods such as that in U.S. Pat. No. 6,917,704 disclosed below have been proposed.
According to the method in U.S. Pat. No. 6,917,704, the dispersal of colors (color components) R (red), G (green), and B (blue) in a small region (block) included in image data is calculated, and the color (color component) for which that dispersal is largest is set as a target color. The average value of this target color in the small region is obtained. Then, the pixels in the small region are divided into groups based on that average value. More specifically, those pixels are divided into a group of pixels with a higher darkness value than the average value of that target color, and a group of pixels with a lower darkness value than the average value of that target color. Next, the average value of the darkness value of each color component of the pixels in each group is obtained, and the color expressed by that average value is set as a representative color of each group. Then, a determination is made of whether or not the number of representative colors obtained is equal to or greater than a desired number of colors, and if the number of colors is less than the desired number of colors, further division into groups is performed. If the number of colors is equal to or greater than the desired number of colors, processing is then performed for the next small region.
With BTC, in this manner, the image in a block is converted to an image with small number of colors. The amount of data is reduced by allowing some amount of reduction in image quality due to this conversion.
Here, a case is considered in which an image conversion is performed using BTC, for a block BK shown in FIG. 16A. Note that, in the original image of an image shown in FIG. 16A, a hatched portion is expressed in blue and a background portion around the hatched portion is expressed in gradations of red. Shown in the block BK is an image expressed by pixels in the block BK, the image including a line drawing portion JS that shows a line drawing and a background portion that is a background of the line drawing portion JS. As shown in FIG. 16A, the color of the background portion gradually grows darker toward the lower right of the block BK.
When considering conversion of the image in this sort of block BK to an image expressed with two approximate colors in BTC processing, it is desirable to be able to convert to an image like that shown in FIG. 16B, in which it is possible to distinguish between the line drawing portion JS and the background portion. Because an approximate color is substituted for the color of each pixel, a reduction in image quality in the block BK is unavoidable, but because the block BK itself is sufficiently small, even if the image quality of each block BK is reduced somewhat, a reduction in the image quality of the image as a whole is essentially not observed.
However, when this sort of method of U.S. Pat. No. 6,917,704 is applied to the block BK, there may be cases where it is not possible to convert to an image like that in FIG. 16B, in which the line drawing portion JS and the background portion are appropriately separated. For example, there may be cases where the darkness values of respective pixels in the block BK are related in the manner shown in FIG. 17. Note that in FIG. 17, a L*a*b* (Lab) color space is used, not an RGB color space.
FIG. 17 shows the distribution of pixels in the block BK for color components “L” and “b”. In FIG. 17, line JL indicates the average value of the darkness value of “L” of pixels in the block BK.
In the example in FIG. 17, it is understood that with respect to the “L” color component, the pixels of the background portion are distributed crossing the average value.
In this case, when the “L” color component is selected as the target color, a portion of the pixels of the background portion is classified in the same group as the pixels of the line drawing portion JS, and that portion is converted to the same approximate color as the line drawing portion JS. Thus, the image after conversion becomes as shown in FIG. 18.
As is understood from FIG. 18, in a portion of the background portion that has been converted to the same approximate color as the line drawing portion JS, the color becomes dark and so that portion stands out from the other pixels of the background portion. When viewing the image as a whole, that portion may appear as noise in the form of a black point. When there are many such portions, the image quality of the image as a whole is greatly reduced.